#include"../include/ConfigFile.h"
#include<fstream>
#include<sstream>
using namespace std;
ConfigFile *ConfigFile::_ptr = ConfigFile::getInstance();

ConfigFile *ConfigFile::getInstance()
{
    if(_ptr == nullptr)
    {
        _ptr = new ConfigFile();
    }
    return _ptr;
}

void ConfigFile::destroy()
{
    if(_ptr)
    {
        delete _ptr;
        _ptr = nullptr;
    }
}

map<string,string> &ConfigFile::getConf()
{
    return _conf;
}

ConfigFile::ConfigFile()
{
    fstream fread("../config/setting.conf");
    if(!fread.good())return ;
    string lines;
    while(getline(fread,lines))
    {
        stringstream ss;
        ss<<lines;
        string key,value;
        ss>>key>>value;
        _conf[key] = value;
    }
    fread.close();
}

ConfigFile::~ConfigFile()
{
    ;
}